<template>
    <div>
        <!-- 顶部滑动条区域 -->
        <div id="slider" class="mui-slider ">
            <div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
                <div class="mui-scroll">
                    <a :class="['mui-control-item',item.id == 0?'mui-active':'']" v-for="item in cates" :key="item.id" @tap="getPhotoListByCateId(item.id)">
                        {{item.title}}
                    </a>
                </div>
            </div>
        </div> 
        <!-- 图片内容区域 -->
        <div class="photos">
            <ul>
                <router-link tag="li" :to="'/home/PhotoInfo/'+item.id" v-for="item in list" :key="item.id">
                    <img v-lazy="item.img_url">
                    <div class="info">
                        <h3>{{item.title}}</h3>
                        <div class="body">{{item.zhaiyao}}</div>
                    </div>
                </router-link>
            </ul>
        </div>
    </div>
</template>
<script>
// 导入MUI的JS文件
import mui from '../lib/mui-master/examples/hello-mui/js/mui.min.js'
// 初始化滑动控件
export default {
    data(){
        return {
            // 所有分类的列表数组
            cates:[
                {id:0,title:'全部'},
                {id:1,title:'生活'},
                {id:2,title:'新闻'},
                {id:3,title:'科技'},
                {id:4,title:'宇宙'},
                {id:5,title:'爱眼'},
                {id:6,title:'淘货'},
            ],
            // 图片内容列表
            list:[
                {id:1,title:'科技至上',img_url:'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=383389798,4141025305&fm=27&gp=0.jpg',zhaiyao:'科技来源于生活'},
                {id:2,title:'宇宙万物',img_url:'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4247227933,2550503478&fm=27&gp=0.jpg',zhaiyao:'宇宙尽头即为玄学'},
                {id:3,title:'宇宙万物',img_url:'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4247227933,2550503478&fm=27&gp=0.jpg',zhaiyao:'宇宙尽头即为玄学'},
                {id:4,title:'宇宙万物',img_url:'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4247227933,2550503478&fm=27&gp=0.jpg',zhaiyao:'宇宙尽头即为玄学'}
            ]
        }
    },
    created(){
        this.getPhotoListByCateId(0);
    },
    mounted(){
        mui('.mui-scroll-wrapper').scroll({
            deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
        });
    },
    methods:{
        getAllCategory(){
            // 获取所有图片分类
        },
        getPhotoListByCateId(cateId){
            // 根据分类ID获取对应的图片列表
            // this.$http.get('路径'+cateId).then(result=>{
                //     if(状态成功){
                //         this.list = result.body.massage;
                //     }
                // })
        }
    }
}
</script>
<style lang="scss">
*{
    touch-action: pan-y;
}
.photos{
    ul{
        list-style: none;
        margin: 0;
        padding: 10px;
        li{
            background-color: gray;
            border-radius: 1%;
            box-shadow: 0 0 9px #999;
            margin-bottom: 10px;
            position: relative;
            img{
                width: 100%;
                border-radius: 1%;
                vertical-align: middle;
            }
            img[lazy=loading] {
                width: 40px;
                height: 300px;
                margin: auto;
            }
            .info{
                position: absolute;
                bottom: 0;
                color: white;
                background-color: rgba(0, 0, 0, 0.5);
                width: 100%;
                max-height: 84px;
                h3{
                    font-size: 13px;
                    text-indent: 2em;
                }
                .body{
                    font-size: 12px;
                    text-indent: 2em;
                }
            }
        }
    }
}
</style>


